package cn.zcib.tms.web;

import cn.zcib.tms.dao.UserMapper;
import cn.zcib.tms.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@Controller
public class UserController {

    @Autowired
    UserMapper userMapper;

    @GetMapping({"/", "/index"})
    public String index() {
        return "index";
    }

    @GetMapping("/test")
    public void test(HttpServletRequest request, HttpServletResponse response) throws IOException {
        List<User> users=userMapper.selectByExample(null);
        StringBuilder sb=new StringBuilder();
        for(User user: users){
            sb.append(user.toString());
        }
        response.getWriter().write(sb.toString());
    }
}
